package com.neuronbit.businessflow.intellij.model;

import org.apache.commons.lang3.StringUtils;

/**
 * The type Simple type.
 */
public class SimpleType implements Type {
    private String name;
    private String qualifiedName;

    private SimpleType(String qualifiedName) {
        this.qualifiedName = qualifiedName;
        if (qualifiedName.contains(".")) {
            this.name = StringUtils.substringAfterLast(qualifiedName, ".");
        } else {
            this.name = qualifiedName;
        }
    }

    /**
     * Of simple type.
     *
     * @param qualifiedName the qualified name
     * @return the simple type
     */
    public static SimpleType of(String qualifiedName) {
        return new SimpleType(qualifiedName);
    }

    @Override
    public String getQualifiedName() {
        return qualifiedName;
    }

    @Override
    public String getName() {
        return name;
    }
}
